package demo.listener;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author : GuoFei
 * @date : 2019/4/26 15:48
 */
@Data
@NoArgsConstructor
public class Robot {

    private RobotListener listener;

    private String name;

    /**
     * 注册机器人监听器
     *
     * @param listener
     */
    public void registerListener(RobotListener listener) {
        this.listener = listener;
    }

    /**
     * 工作
     */
    public void working() {
        if (listener != null) {
            Even even = new Even(this);
            this.listener.working(even);
        }
        System.out.println("机器人开始工作......");
    }

    /**
     * 跳舞
     */
    public void dancing() {
        if (listener != null) {
            Even even = new Even(this);
            this.listener.dancing(even);
        }
        System.out.println("机器人开始跳舞......");
    }

    public Robot(String name) {
        this.name = name;
    }
}
